#include using std::cin; using std::cout; using std::endl; const int MAX_STRING_LENGTH = 100; //'a' vs "a" int stringLength(char s[]) { int result = 0; while(s[result]!= '\0') { result++; } return result; } void stringCopy(char destination[], char source[]) { int i = 0; do { destination[i] = source[i]; i++; } while(source[i-1] != '\0'); } //bool sameStrings(char s1[], char s2[]) //{ // //return true if they have the same chars in the arrays // //} // //bool sameStringsCaseInsensitive(char s1[], char s2[]) //{ // //return true if they have the same chars in the arrays // //hint: toupper(s1[i]) //} // //void stringAppend(char destination[], char source[]) //{ // //copy all of the chars from source to the end of the destination // //} // //int indexOfChar(char s[], char c) //{ // //return the first index in string s where the char c is found // //return -1 if it is not found //} void main() { //char name[MAX_STRING_LENGTH] = {'a','b','c','\0'}; //cout << name << endl; //char name2[] = "abc"; //cout << name2 << endl; ////cin >> name; ////cout << name << endl; //cin.getline(name,MAX_STRING_LENGTH); //cout << name << endl; //cout << "The lenght of \"" << name << "\" is " << stringLength(name) << endl; char x[1000] = "This is the day the Lord has made"; char y[1000] = "apple"; //stringCopy(x + stringLength(x),y); //stringCopy(x, x+5); //cout << x << endl; cout << strlen(x) << endl; strcpy(y,x); cout << y << endl; char z[1000]; strncpy(z,x,4); z[4] = '\0'; cout << z << endl; strncat(y,", I will be glad and rejoice in it.",10); cout << y << endl; cin.getline(x,1000); cin.getline(y,1000); //strcmp, stricmp, strncmp, strnicmp if(strnicmp(x,y,4) == 0) { cout << "They match" << endl; } else if(stricmp(x,y) > 0) { cout << x << " is greater than " << y << endl; } else { cout << x << " is less than " << y << endl; } }